home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-28 | 2.7 KB | 120 lines | [TEXT/PJMM] |
- {P4/Mac port by Ingemar Ragenamlm 1994-1996}
-
- unit Run;
-
- interface
- uses
- {$IFC UNDEFINED THINK_PASCAL}
- Types, QuickDraw, Windows, Dialogs, ToolUtils, Events, Controls, {}
- Memory, Sound, OSUtils, MixedMode,
- {$ENDC}
- TransEdit, TransSkel, EditWindow, pascalcompiler, pcode, Messages;
-
- procedure Run;
- procedure Compile;
- procedure RunPcode;
-
- implementation
-
- procedure DoRun (runFlag: Boolean);
- var
- fileInfo: SFReply;
- newFile: Str255;
- saved: Boolean;
- function CommandPeriod: Boolean;
- var
- km: KeyMap;
- begin
- CommandPeriod := false;
- GetKeys(km);
- if km[47] and km[55] then
- CommandPeriod := true;
- end; {CommandPeriod}
- begin
- {Hämta främsta editfönstrets text}
- {Kör det i compiler}
- {Fel skall skrivas i ett error-fönster.}
- {Resultatet skall sparas i MINNET och skickas}
- {direkt till run!}
- {}
- {Ett körfönster öppnas och skall HELST köras}
- {som kooperativ thread }
-
- if FrontWindow <> nil then
- begin
- saved := EWindowSave(FrontWindow);
- if GetEWindowFile(FrontWindow, @fileInfo) then
- begin
- HideWindow(messagesWind);
-
- if SetVol(nil, fileInfo.vRefNum) <> noErr then
- ; {We ignore errors for now}
-
- {Is the open window pcode?}
- if Length(fileInfo.fName) > Length('.pcode') then
- if Copy(fileInfo.fName, Length(fileInfo.fName) - Length('.pcode') + 1, Length('.pcode')) = '.pcode' then
- begin
- if runFlag then
- RunInterpreter(fileInfo.fName);
- Exit(DoRun);
- end;
-
- newFile := RunCompiler(fileInfo.fName);
- if runFlag then
- if newFile <> '' then
- if not CommandPeriod then
- {Kan man inte stoppa om det blev kompileringsfel?}
- RunInterpreter(newFile);
- Exit(DoRun);
- end;
- end;
-
- {If we get here, then the open window was not usable. Run compiler with no file name.}
- {That will cause it to prompt for a file.}
- newFile := RunCompiler('');
- if runFlag then
- if newFile <> '' then
- RunInterpreter(newFile);
- end; {DoRun}
-
-
- procedure Run;
- begin
- DoRun(true);
- end; {Run}
-
- procedure Compile;
- begin
- DoRun(false);
- end; {Compile}
-
- procedure RunPcode;
- var
- fileInfo: SFReply;
- newFile: Str255;
- begin
-
- if FrontWindow <> nil then
- begin
- if GetEWindowFile(FrontWindow, @fileInfo) then
- begin
- HideWindow(messagesWind);
-
- if SetVol(nil, fileInfo.vRefNum) <> noErr then
- ; {We ignore errors for now}
-
- newFile := fileInfo.fName;
- if Length(fileInfo.fName) > Length('.p') then
- if Copy(fileInfo.fName, Length(fileInfo.fName) - Length('.p') + 1, Length('.p')) = '.p' then
- begin
- newFile := ConCat(Copy(fileInfo.fName, 1, Length(fileInfo.fName) - 2), '.pcode');
- end;
-
- if newFile <> '' then
- RunInterpreter(newFile);
- end;
- end;
-
- end; {RunPcode}
-
- end.